// Copyright 2022 Hollson. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package main

import (
	"fmt"
)

// Node 二叉树的「度」「层」「高」
type Node struct {
	Data  interface{}
	Left  *Node
	Right *Node
}

func (root *Node) LevelTravesal() {
	if root == nil {
		return
	}

	linkedList := queue.New()
	linkedList.Offer(root)

	for !linkedList.IsEmpty() {
		cur := linkedList.Poll().(*Node)
		fmt.Println(cur.Data)

		if cur.Left != nil {
			linkedList.Offer(cur.Left)
		}

		if cur.Right != nil {
			linkedList.Offer(cur.Right)
		}
	}
}

// https://blog.csdn.net/u010189308/article/details/79807613
// https://blog.csdn.net/qq_30505673/article/details/84866519
// https://blog.csdn.net/qq_36183935/article/details/80249395
// https://www.jianshu.com/p/bf73c8d50dc2
